if __name__ == '__main__':
    maxNum = 0
    inStr = input()
    stack = []
    i = 0
    j = len(inStr) - 1

    #遇到前括号入栈 遇到后括号push出一个前括号
    if j == -1:
        print(0)
    else :
        while i != j:
            if inStr[i] != '(':
                i += 1
                continue
            num = 0
            for index in range(i, j + 1):
                if inStr[index] == '(':
                    stack.append('(')
                elif len(stack) == 0:
                    break
                else:
                    num += 2
                    stack.pop()
            if (len(stack) == 0):
                maxNum = max(num, maxNum)
            i += 1
            stack.clear()

        print(maxNum)